package top.riske.animalhazardassessment.animal.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import top.riske.animalhazardassessment.animal.service.SpeciesService;
import top.riske.animalhazardassessment.common.entity.Species;

import java.util.List;

@Tag(name = "SpeciesController",description = "物种信息控制类")
@RestController
public class SpeciesController {

    @Resource
    private SpeciesService speciesService;

    @Operation(summary = "获取所有物种信息")
    @GetMapping("/species/get")
    public List<Species> getSpecies(){
        return speciesService.getSpecies();
    }

    @Operation(summary = "更新物种信息")
    @PostMapping("/admin/species/update")
    public boolean updateSpecies(@RequestBody Species species) {
        return speciesService.updateById(species);
    }

    @Operation(summary = "删除物种信息")
    @GetMapping("/admin/species/delete")
    public boolean deleteSpecies(@RequestParam Long id) {
        return speciesService.removeById(id);
    }

    @Operation(summary = "新增物种信息")
    @PostMapping("/admin/species/add")
    public boolean addSpecies(@RequestBody Species species) {
        return speciesService.save(species);
    }

}
